package com.project.service.imp;

import com.project.bean.ClassBean;
import com.project.dao.IClassDao;
import com.project.dao.IStudentDao;
import com.project.dao.IUserDao;
import com.project.service.ClassService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ClassServiceImp implements ClassService {
    @Autowired
    private IClassDao dao;
    @Autowired
    private IStudentDao stuDao;

    @Override
    public List<ClassBean> findAll() {
        return dao.findAll();
    }

    @Override
    public void add(ClassBean classBean) {
        dao.add(classBean);
    }

    @Override
    public boolean del(Integer id) {
        if (stuDao.countByClass(id) == 0) {
            dao.del(id);
            return true;
        }
        return false;
    }

    @Override
    public ClassBean findByName(String name) {
        System.out.println(dao.findByName(name));
        return dao.findByName(name);
    }
}

